note (Anki)のguid生成algorithm
code:rs
pub(crate) fn base91_u64() -> String {
anki_base91(rand::random())
}
fn anki_base91(n: u64) -> String {
to_base_n(
n,
b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&()*+,-./:;<=>?@[]^_`{|}~",
)
}
pub fn to_base_n(mut n: u64, table: &u8) -> String { let mut buf = String::new();
while n > 0 {
let tablelen = table.len() as u64;
let (q, r) = (n / tablelen, n % tablelen);
n = q;
}
buf.chars().rev().collect()
}